home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT27.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  3.2 KB  |  81 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 27                         
  5.                                                                               
  6.  Draws some circles, captures a block, and skews the block while rotating    
  7.  the colors.                                                                 
  8.                                                                               
  9.  *** PROJECT ***                                                             
  10.  This program requires the file WGT5_WC.LIB to be linked.                    
  11.                                                                               
  12.  *** DATA FILES ***                                                          
  13.  NONE                                                                        
  14.                                                            WATCOM C++ VERSION 
  15. ==============================================================================
  16. */
  17.  
  18. #include <conio.h>
  19. #include <wgt5.h>
  20.  
  21.  
  22. void main(void)
  23. {
  24.   block skewit;                 /* Pointer to our block */
  25.   color palette[256];           /* Our palette */
  26.   short oldmode;                /* Store initial video mode */
  27.   short i = 0;                  /* Loop counter */
  28.  
  29.   if ( !vgadetected () )
  30.   {
  31.     printf("Error - VGA card required for any WGT program.\n");
  32.     exit (0);
  33.   }
  34.   printf ("WGT Example #27\n\n");
  35.   printf ("A bitmap is skewed left and right while the palette is rotated.\n");
  36.   printf ("Press a key to end the program at any time.\n");
  37.   printf ("\n\nPress any key to continue.\n");
  38.   getch ();
  39.  
  40.  
  41.   oldmode = wgetmode ();           /* Gets the current mode */
  42.   vga256 ();                       /* Initialize graphics mode */
  43.  
  44.   wreadpalette (0, 255, palette);  /* Store our current palette */
  45.  
  46.   wcls (0);                        /* Clear screen with black */
  47.  
  48.   for (i = 100; i > 0; i--)        /* Draw 100 filled circles */
  49.   {
  50.     wsetcolor (i);
  51.     wfill_circle (160, 100, i);
  52.   }
  53.  
  54.   wsetcolor (0);                    /* Use black as active color */
  55.   wbar (0, 0, 104, 199);            /* Draw two solid rectangles */
  56.   wbar (216, 0, 319, 199);
  57.   skewit = wnewblock (100, 40, 220, 160);     /* Grab a block for skewing */
  58.  
  59.   wcls (0);                              /* Clear screen with black */
  60.   do
  61.   {
  62.     for (i = -100; i < 100; i += 2)      /* Skew image 2 pixels at a time */
  63.     {
  64.       wretrace ();
  65.       wskew (100, 40, skewit, i);
  66.       wcolrotate (1, 100, 0, palette);   /* Rotate palette too */
  67.       wsetpalette (1, 100, palette);     /* And show palette changes */
  68.     }
  69.     for (i = 100; i > -100; i -= 2)      /* Skew image back to starting pos */
  70.     {
  71.       wretrace ();
  72.       wskew (100, 40, skewit, i);
  73.       wcolrotate (1, 100, 0, palette);   /* Rotate palette */
  74.       wsetpalette (1, 100, palette);     /* Show palette changes */
  75.     }
  76.   } while (!kbhit ());                   /* Stop when key is pressed */
  77.  
  78.   getch ();
  79.   wsetmode (oldmode);                    /* Restore initial video mode */
  80. }
  81.